Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attempt to estimate world in teleport when it's not specified. #6611

Merged
merged 8 commits into from
Jul 1, 2024

Conversation

Moderocky
Copy link
Member

Description

I previously tried to fix this issue in the Entity utils teleport method, by estimating their target world from their source world if it wasn't specified.

Unfortunately, EffTeleport does a lot of stuff that isn't teleporting (like setting the move event target, loading the chunk), so the last patch didn't fix that.

This time I do my best to estimate a location in all cases if I can, or just return if I can't.
It's not ideal, but it's the best we can do to avoid an error while not just failing silently with no feedback for the user about why their teleport did nothing.

Are there any more of these?

Probably, but the only way to find them would be to check every single usage of Location across all 500 and so files, and it's very hit-or-miss whether Bukkit requires a location or not.


Target Minecraft Versions: any
Requirements: none
Related Issues: fixes #6610

@Moderocky Moderocky added bug An issue that needs to be fixed. Alternatively, a PR fixing an issue. 2.8 Targeting a 2.8.X version release labels Apr 26, 2024
Comment on lines 132 to 141
if (unknownWorld) { // we can't fetch the chunk without a world
for (Entity entity : entityArray) {
if (entity == null)
continue;
// assume it's a local teleport, use the first entity we find as a reference
loc = new Location(entity.getWorld(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
break find_a_world;
}
return next; // no entities = no chunk = nobody teleporting
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% convinced this is great, but it seems like a very good assumption most of the time so whatever

if (entity == null)
continue;
// assume it's a local teleport, use the first entity we find as a reference
loc = new Location(entity.getWorld(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
loc = new Location(entity.getWorld(), loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch());
loc = loc.clone();
loc.setWorld(entity.getWorld());

src/main/java/ch/njol/skript/effects/EffTeleport.java Outdated Show resolved Hide resolved
@Moderocky Moderocky added 2.9 Targeting a 2.9.X version release and removed 2.8 Targeting a 2.8.X version release labels May 1, 2024
@APickledWalrus APickledWalrus deleted the branch SkriptLang:dev/patch June 1, 2024 19:39
@APickledWalrus APickledWalrus reopened this Jun 1, 2024
@APickledWalrus APickledWalrus merged commit 2f629f1 into SkriptLang:dev/patch Jul 1, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.9 Targeting a 2.9.X version release bug An issue that needs to be fixed. Alternatively, a PR fixing an issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants